from django.db import models


# Create your models here.


# pod表
# name
# git下目录
# 创建时间
# type
# 备注
class Pod(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=128)
    type = models.CharField(max_length=32)
    templates = models.CharField(max_length=32)
    folder = models.CharField(max_length=512)
    create_date = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# git仓库地址
# id
# type
# 仓库地址
# 仓库名称
# 创建时间
# 备注
class Vm(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    outer_ip = models.CharField(max_length=32)
    inner_ip = models.CharField(max_length=512)
    create_date = models.CharField(max_length=32)
    username = models.CharField(max_length=32)
    pwd = models.CharField(max_length=32)
    cpu = models.CharField(max_length=32)
    memory = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)
    disk = models.CharField(max_length=32)
    system = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# git和产品线关联
# id
# gitid
# 产品线id
# 备注
class Vm_hm(models.Model):
    id = models.AutoField(primary_key=True)
    vmid = models.CharField(max_length=32)
    hmid = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# git和pod关联表
# id
# gitid
# podid
# 备注
class Git_pod(models.Model):
    id = models.AutoField(primary_key=True)
    gitid = models.CharField(max_length=32)
    podid = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 产品线
# name
# 负责人
# 创建时间
# 备注
class Host_Machine(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=512)
    nameuser = models.CharField(max_length=32)
    create_date = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)
    sn_code = models.CharField(max_length=32)
    cpu = models.CharField(max_length=64)
    memory = models.CharField(max_length=32)
    username = models.CharField(max_length=32)
    pwd = models.CharField(max_length=32)
    disk = models.CharField(max_length=64)
    system = models.CharField(max_length=32)
    outer_ip = models.CharField(max_length=32)


    def __str__(self):
        return self.name


# 用户
# id
# 用户名
# 真实名称
##密码
# 邮箱
# 创建时间
# 备注
class Users(models.Model):
    id = models.AutoField(primary_key=True)
    username = models.CharField(max_length=32)
    name = models.CharField(max_length=32)
    pwd = models.CharField(max_length=32)
    emil = models.CharField(max_length=32)
    create_date = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 配置文件表
class conf(models.Model):
    id = models.AutoField(primary_key=True)
    servername = models.CharField(max_length=32)
    ip = models.CharField(max_length=32)
    port = models.CharField(max_length=32)
    user = models.CharField(max_length=32)
    pwd = models.CharField(max_length=32)
    token = models.CharField(max_length=1024)
    create_date = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 机器表
class machine(models.Model):
    id = models.AutoField(primary_key=True)
    purpose = models.CharField(max_length=32)
    ip = models.CharField(max_length=32)
    ip1 = models.CharField(max_length=32)
    user = models.CharField(max_length=128)
    pwd = models.CharField(max_length=128)
    post = models.CharField(max_length=32)
    create_date = models.CharField(max_length=32)
    name = models.CharField(max_length=32)
    emil = models.CharField(max_length=128)
    status = models.CharField(max_length=32)
    relevance = models.CharField(max_length=32)
    remark = models.CharField(max_length=128)

    def __str__(self):
        return self.name


# 定时任务表
##定时任务和命令关联表
class order(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=128)
    relevance = models.CharField(max_length=32)
    relevanceid = models.CharField(max_length=32)
    relevancecmd = models.CharField(max_length=32)
    relevancecmdid = models.CharField(max_length=32)
    relevancecmd1 = models.CharField(max_length=32)
    relevancecmdid1 = models.CharField(max_length=32)
    timestart = models.CharField(max_length=32)
    create_date = models.CharField(max_length=128)
    remark = models.CharField(max_length=128)

    def __str__(self):
        return self.name


# 命令表
class Command(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=128)
    cmd1 = models.CharField(max_length=512)
    cmd2 = models.CharField(max_length=512)
    cmd3 = models.CharField(max_length=512)
    cmd4 = models.CharField(max_length=512)
    cmd5 = models.CharField(max_length=512)
    cmd6 = models.CharField(max_length=512)
    cmd7 = models.CharField(max_length=512)
    cmd8 = models.CharField(max_length=512)
    cmd9 = models.CharField(max_length=512)
    create_date = models.CharField(max_length=128)
    remark = models.CharField(max_length=128)

    def __str__(self):
        return self.name


# 菜单
# id
# name
# url
class Menu(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    url = models.CharField(max_length=512)
    type = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 角色
# id
# name
# 备注
#  权限
# 属性
# 创建时间
class Role(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=512)
    create_date = models.CharField(max_length=32)
    jurisdiction = models.CharField(max_length=32)
    type = models.CharField(max_length=32)
    remark = models.CharField(max_length=512)

    def __str__(self):
        return self.name


# 角色关联菜单
# id
# 角色id
# 菜单id
# 备注
class Role_menu(models.Model):
    id = models.AutoField(primary_key=True)
    roleid = models.CharField(max_length=32)
    menuid = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 用户关联角色一个关联表
# id
# 用户表id
# 角色表id
# 备注

class Users_role(models.Model):
    id = models.AutoField(primary_key=True)
    userid = models.CharField(max_length=32)
    roleid = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 任务关联机器
# 任务id
# 机器id
class Order_machine(models.Model):
    id = models.AutoField(primary_key=True)
    orderid = models.CharField(max_length=32)
    machineid = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 用户组
# id
# 组名
# 创建时间
# 备注
class Users_group(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    create_date = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 用户关联用户组
# id
# 组id
# 用户id
# 备注
class Users_group_relevance(models.Model):
    id = models.AutoField(primary_key=True)
    groupid = models.CharField(max_length=32)
    usersid = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 用户组 产品线关联
# 用户id
# 产品id
# 备注
class Users_group_hm(models.Model):
    id = models.AutoField(primary_key=True)
    groupid = models.CharField(max_length=512)
    hmid = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 机器组
# id
# 组名
# 创建时间
# 备注
class colony(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    create_date = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# 机器组关联命令
# id
# 组id
# 命令id
# 备注
class Colony_command(models.Model):
    id = models.AutoField(primary_key=True)
    colonyid = models.CharField(max_length=32)
    commandid = models.CharField(max_length=32)
    remark = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# dev镜像表
class Devimage(models.Model):
    id = models.AutoField(primary_key=True)
    type = models.CharField(max_length=128)
    name = models.CharField(max_length=128)
    version = models.CharField(max_length=128)
    host = models.CharField(max_length=512)
    create_date = models.CharField(max_length=128)
    create_by = models.CharField(max_length=128)
    remark = models.CharField(max_length=128)
    status = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# test镜像表
class Testimage(models.Model):
    id = models.AutoField(primary_key=True)
    type = models.CharField(max_length=128)
    name = models.CharField(max_length=128)
    version = models.CharField(max_length=128)
    host = models.CharField(max_length=512)
    create_date = models.CharField(max_length=128)
    create_by = models.CharField(max_length=128)
    remark = models.CharField(max_length=128)
    status = models.CharField(max_length=32)

    def __str__(self):
        return self.name


# main镜像表
class Mainimage(models.Model):
    id = models.AutoField(primary_key=True)
    type = models.CharField(max_length=128)
    name = models.CharField(max_length=128)
    version = models.CharField(max_length=128)
    host = models.CharField(max_length=512)
    create_date = models.CharField(max_length=128)
    create_by = models.CharField(max_length=128)
    remark = models.CharField(max_length=128)
    status = models.CharField(max_length=32)

    def __str__(self):
        return self.name


class Pipelinetemplates(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=64, verbose_name="名称")
    templates = models.TextField(verbose_name="模板", null=True)
    remark = models.TextField(verbose_name="备注", null=True)
    objects = models.Manager()

    def __str__(self):
        return self.name


class Release(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=64)
    version = models.CharField(max_length=32)
    apply_date = models.CharField(max_length=64)
    apply_by = models.CharField(max_length=64)
    remark = models.CharField(max_length=64)

    def __str__(self):
        return self.name


class Fault(models.Model):
    id = models.AutoField(primary_key=True)
    description = models.CharField(max_length=128)
    system = models.CharField(max_length=32)
    occur_date = models.CharField(max_length=64)
    principal = models.CharField(max_length=64)
    process = models.CharField(max_length=64)
    remark = models.CharField(max_length=64)

    def __str__(self):
        return self.name


class Backup(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=128)
    times = models.CharField(max_length=32)
    principal = models.CharField(max_length=64)
    status = models.CharField(max_length=64)
    remark = models.CharField(max_length=64)

    def __str__(self):
        return self.name
